import { requestClient } from '#/api/request';
import type { PageResult } from '#/api/common';
import type { TableVO, TableForm, TableQuery } from '#/api/demo/table/types';

/**
 * 查询数据列表
 * @param query
 * @returns {*}
 */

export const listTable = (query?: TableQuery) =>
  requestClient.get<PageResult<TableVO>>('/data/table/list', { params: query });

/**
 * 查询数据详细
 * @param id
 */
export const getTable = (id: string | number) =>
  requestClient.get<TableVO>(`/data/table/${id}`);

/**
 * 新增数据
 * @param data
 */
export const addTable = (data: TableForm) =>
  requestClient.postWithMsg<void>('/data/table', data);

/**
 * 修改数据
 * @param data
 */
export const updateTable = (data: TableForm) =>
  requestClient.putWithMsg<void>('/data/table', data);

/**
 * 删除数据
 * @param id
 */
export const delTable = (id: string | number | Array<string | number>) =>
  requestClient.deleteWithMsg<void>(`/data/table/${id}`);
